package $NAMESPACE.domain.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ugeez.commons.mybatisplus.service.impl.AbstractServiceImpl;
import $NAMESPACE.common.enums.XXXEnum;
import $NAMESPACE.domain.service.SomeEntityService;
import $NAMESPACE.persistence.dao.SomeEntityMapper;
import $NAMESPACE.persistence.entity.SomeEntity;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class SomeEntityServiceImpl extends AbstractServiceImpl<SomeEntityMapper, SomeEntity> implements SomeEntityService {
    @Override
    public SomeEntity create(Long userId,
							 XXXEnum xxx,
							 Map<String, Object> biz) {
        SomeEntity doc = new SomeEntity();
        doc.setUserId(userId);
        doc.setXxx(xxx);
		
		if (biz == null) {
			biz = new HashMap();
		}
        doc.setBiz(biz);

        this.save(doc);

        return doc;
    }

    @Override
    public IPage<SomeEntity> getByUserId(Long userId, long page, long pageSize) {
        return this.baseMapper.selectByUserId(userId, new Page<>(page, pageSize));
    }
}
